Skip to content

fix(delegation): honor direct endpoint api_key_env#48579

Open
Veritas-7 wants to merge 2 commits into
NousResearch:mainfrom
Veritas-7:fix/delegation-api-key-env-20260619
Open

fix(delegation): honor direct endpoint api_key_env#48579
Veritas-7 wants to merge 2 commits into
NousResearch:mainfrom
Veritas-7:fix/delegation-api-key-env-20260619

Conversation

@Veritas-7

@Veritas-7 Veritas-7 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Resolve delegation.api_key_env for direct delegation endpoints before falling back to parent credential inheritance.
  • Strip env-derived key values and raise a clear ValueError when the configured env var is missing or empty.
  • Add regression tests for env-key resolution, whitespace stripping, missing env handling, and unchanged parent-key inheritance when no env key is configured.
  • Add the contributor attribution mapping required by the repository's check-attribution workflow for this PR author email.

Problem

Direct delegation endpoints can point at providers whose key lives outside the parent agent's API key. If delegation.api_key_env is configured but not resolved, the child can inherit an unrelated parent key and fail authentication against the direct endpoint.

Tests

  • git diff --check origin/main...HEAD
  • python3 -m py_compile tools/delegate_tool.py scripts/release.py
  • python3 -m pytest tests/tools/test_delegate.py::TestDelegationCredentialResolution -q -o 'addopts=' → 19 passed
  • local reproduction of check-attribution email mapping → pass
  • gitleaks detect --source . --no-banner --redact --log-opts='origin/main..HEAD' → no leaks found
  • private-path/token regex scan over candidate diff → no hits

Note: full tests/tools/test_delegate.py currently has an unrelated heartbeat test failure on origin/main; this PR's focused credential suite passes.

Veritas-7 and others added 2 commits June 19, 2026 03:29
Use delegation.api_key_env when resolving direct endpoint credentials so custom delegation endpoints can receive their provider-specific key instead of inheriting an unrelated parent key.

Add regression coverage for a custom direct endpoint using GLM_API_KEY.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation area/auth Authentication, OAuth, credential pools labels Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants